package com.study.leetcode;

import java.util.Stack;

public class Solution_1614 {
    public static int maxDepth(String s) {
        int maxDepth = 0;
        Stack<String> stack = new Stack<>();
        for (int i = 0; i < s.length(); i++) {
            char c = s.charAt(i);
            if (c == '(') {
                stack.push(String.valueOf(c));
                if (maxDepth < stack.size()) {
                    maxDepth = stack.size();
                }
            } else if (c == ')') {
                stack.pop();
            }
        }
        return maxDepth;
    }

    public static void main(String[] args) {
        int i = maxDepth("1+1+1+(1)+((2))+(((3)))");
        System.out.println("i = " + i);
    }
}
